package com.sea.physical.service.impl;

import com.codecrane.core.util.CountryEnum;
import com.sea.physical.entity.Coefficient;
import com.sea.physical.mapper.CoefficientMapper;
import com.sea.physical.service.CoefficientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CoefficientServiceImpl implements CoefficientService
{
    @Autowired
    private CoefficientMapper coefficientMapper;

    @Override
    public List<Coefficient> findByCnd(Coefficient coefficient) {
        return coefficientMapper.findByCnd(coefficient);
    }

    @Override
    public int delete(Integer id) {
        return coefficientMapper.delete(id);
    }

    @Override
    public int save(Coefficient coefficient) {
        coefficient.setCoefficientName(CountryEnum.getCountry(Integer.parseInt(coefficient.getCoefficientCode())));
        return coefficientMapper.insert(coefficient);
    }

    @Override
    public int usave(Coefficient coefficient) {
        return coefficientMapper.update(coefficient);
    }

    @Override
    public Coefficient findByCountry(String country) {
        return coefficientMapper.findByCountry(country);
    }
}
